<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class JSON::Ext::Generator::State - json: Ruby Standard Library Documentation</title>


<script src="../../../js/navigation.js" defer></script>
<script src="../../../js/search.js" defer></script>
<script src="../../../js/search_index.js" defer></script>
<script src="../../../js/searcher.js" defer></script>
<script src="../../../js/darkfish.js" defer></script>

<script src="../../../js/jquery-3.2.0.min.js"></script>

<script src="../../../js/vue.min.js"></script>
<script src="../../../js/js.cookie.min.js"></script>

<link href="../../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../../css/rdoc.css" rel="stylesheet">
<link href="../../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../../";
  var index_rel_prefix = "../../../";
  var darkModeCsseHref = "../../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../../table_of_contents.html#pages">Pages</a>
    <a href="../../../table_of_contents.html#classes">Classes</a>
    <a href="../../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-from_state">::from_state</a>
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-5B-5D">#[]</a>
    <li ><a href="#method-i-5B-5D-3D">#[]=</a>
    <li ><a href="#method-i-allow_nan-3F">#allow_nan?</a>
    <li ><a href="#method-i-array_nl">#array_nl</a>
    <li ><a href="#method-i-array_nl-3D">#array_nl=</a>
    <li ><a href="#method-i-ascii_only-3F">#ascii_only?</a>
    <li ><a href="#method-i-buffer_initial_length">#buffer_initial_length</a>
    <li ><a href="#method-i-buffer_initial_length-3D">#buffer_initial_length=</a>
    <li ><a href="#method-i-check_circular-3F">#check_circular?</a>
    <li ><a href="#method-i-configure">#configure</a>
    <li ><a href="#method-i-depth">#depth</a>
    <li ><a href="#method-i-depth-3D">#depth=</a>
    <li ><a href="#method-i-escape_slash">#escape_slash</a>
    <li ><a href="#method-i-escape_slash-3D">#escape_slash=</a>
    <li ><a href="#method-i-escape_slash-3F">#escape_slash?</a>
    <li ><a href="#method-i-generate">#generate</a>
    <li ><a href="#method-i-indent">#indent</a>
    <li ><a href="#method-i-indent-3D">#indent=</a>
    <li ><a href="#method-i-initialize_copy">#initialize_copy</a>
    <li ><a href="#method-i-max_nesting">#max_nesting</a>
    <li ><a href="#method-i-max_nesting-3D">#max_nesting=</a>
    <li ><a href="#method-i-merge">#merge</a>
    <li ><a href="#method-i-object_nl">#object_nl</a>
    <li ><a href="#method-i-object_nl-3D">#object_nl=</a>
    <li ><a href="#method-i-space">#space</a>
    <li ><a href="#method-i-space-3D">#space=</a>
    <li ><a href="#method-i-space_before">#space_before</a>
    <li ><a href="#method-i-space_before-3D">#space_before=</a>
    <li ><a href="#method-i-to_h">#to_h</a>
    <li ><a href="#method-i-to_hash">#to_hash</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-JSON::Ext::Generator::State">
    <h1 id="class-JSON::Ext::Generator::State" class="class">
      class JSON::Ext::Generator::State
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-from_state" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          from_state(opts)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a <a href="State.html"><code>State</code></a> object from <em>opts</em>, which ought to be Hash to create a new <a href="State.html"><code>State</code></a> instance configured by <em>opts</em>, something else to create an unconfigured instance. If <em>opts</em> is a <a href="State.html"><code>State</code></a> object, it is just returned.</p>

                              <div class="method-source-code" id="from_state-source">
            <pre>static VALUE cState_from_state_s(VALUE self, VALUE opts)
{
    if (rb_obj_is_kind_of(opts, self)) {
        return opts;
    } else if (rb_obj_is_kind_of(opts, rb_cHash)) {
        return rb_funcall(self, i_new, 1, opts);
    } else {
        return rb_class_new_instance(0, NULL, cState);
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(opts = {})
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Instantiates a new <a href="State.html"><code>State</code></a> object, configured by <em>opts</em>.</p>

<p><em>opts</em> can have the following keys:</p>
<ul><li>
<p><strong>indent</strong>: a string used to indent levels (default: ”),</p>
</li><li>
<p><strong>space</strong>: a string that is put after, a : or , delimiter (default: ”),</p>
</li><li>
<p><strong>space_before</strong>: a string that is put before a : pair delimiter (default: ”),</p>
</li><li>
<p><strong>object_nl</strong>: a string that is put at the end of a <a href="../../../JSON.html"><code>JSON</code></a> object (default: ”),</p>
</li><li>
<p><strong>array_nl</strong>: a string that is put at the end of a <a href="../../../JSON.html"><code>JSON</code></a> array (default: ”),</p>
</li><li>
<p><strong>allow_nan</strong>: true if NaN, Infinity, and -Infinity should be generated, otherwise an exception is thrown, if these values are encountered. This options defaults to false.</p>
</li><li>
<p><strong>ascii_only</strong>: true if only ASCII characters should be generated. This option defaults to false.</p>
</li><li>
<p><strong>buffer_initial_length</strong>: sets the initial length of the generator’s internal buffer.</p>
</li></ul>

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE cState_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE opts;
    GET_STATE(self);
    state-&gt;max_nesting = 100;
    state-&gt;buffer_initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT;
    rb_scan_args(argc, argv, &quot;01&quot;, &amp;opts);
    if (!NIL_P(opts)) cState_configure(self, opts);
    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-5B-5D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          [](name)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the value returned by method <code>name</code>.</p>

                              <div class="method-source-code" id="5B-5D-source">
            <pre>static VALUE cState_aref(VALUE self, VALUE name)
{
    name = rb_funcall(name, i_to_s, 0);
    if (RTEST(rb_funcall(self, i_respond_to_p, 1, name))) {
        return rb_funcall(self, i_send, 1, name);
    } else {
        return rb_attr_get(self, rb_intern_str(rb_str_concat(rb_str_new2(&quot;@&quot;), name)));
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-5B-5D-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          []=(name, value)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the attribute name to value.</p>

                              <div class="method-source-code" id="5B-5D-3D-source">
            <pre>static VALUE cState_aset(VALUE self, VALUE name, VALUE value)
{
    VALUE name_writer;

    name = rb_funcall(name, i_to_s, 0);
    name_writer = rb_str_cat2(rb_str_dup(name), &quot;=&quot;);
    if (RTEST(rb_funcall(self, i_respond_to_p, 1, name_writer))) {
        return rb_funcall(self, i_send, 2, name_writer, value);
    } else {
        rb_ivar_set(self, rb_intern_str(rb_str_concat(rb_str_new2(&quot;@&quot;), name)), value);
    }
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-allow_nan-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          allow_nan?
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false.</p>

                              <div class="method-source-code" id="allow_nan-3F-source">
            <pre>static VALUE cState_allow_nan_p(VALUE self)
{
    GET_STATE(self);
    return state-&gt;allow_nan ? Qtrue : Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-array_nl" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          array_nl()
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This string is put at the end of a line that holds a <a href="../../../JSON.html"><code>JSON</code></a> array.</p>

                              <div class="method-source-code" id="array_nl-source">
            <pre>static VALUE cState_array_nl(VALUE self)
{
    GET_STATE(self);
    return state-&gt;array_nl ? rb_str_new(state-&gt;array_nl, state-&gt;array_nl_len) : rb_str_new2(&quot;&quot;);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-array_nl-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          array_nl=(array_nl)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This string is put at the end of a line that holds a <a href="../../../JSON.html"><code>JSON</code></a> array.</p>

                              <div class="method-source-code" id="array_nl-3D-source">
            <pre>static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
{
    unsigned long len;
    GET_STATE(self);
    Check_Type(array_nl, T_STRING);
    len = RSTRING_LEN(array_nl);
    if (len == 0) {
        if (state-&gt;array_nl) {
            ruby_xfree(state-&gt;array_nl);
            state-&gt;array_nl = NULL;
        }
    } else {
        if (state-&gt;array_nl) ruby_xfree(state-&gt;array_nl);
        state-&gt;array_nl = fstrndup(RSTRING_PTR(array_nl), len);
        state-&gt;array_nl_len = len;
    }
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-ascii_only-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          ascii_only?
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true, if only ASCII characters should be generated. Otherwise returns false.</p>

                              <div class="method-source-code" id="ascii_only-3F-source">
            <pre>static VALUE cState_ascii_only_p(VALUE self)
{
    GET_STATE(self);
    return state-&gt;ascii_only ? Qtrue : Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-buffer_initial_length" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          buffer_initial_length
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This integer returns the current initial length of the buffer.</p>

                              <div class="method-source-code" id="buffer_initial_length-source">
            <pre>static VALUE cState_buffer_initial_length(VALUE self)
{
    GET_STATE(self);
    return LONG2FIX(state-&gt;buffer_initial_length);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-buffer_initial_length-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          buffer_initial_length=(length)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This sets the initial length of the buffer to <code>length</code>, if <code>length</code> &gt; 0, otherwise its value isn’t changed.</p>

                              <div class="method-source-code" id="buffer_initial_length-3D-source">
            <pre>static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_length)
{
    long initial_length;
    GET_STATE(self);
    Check_Type(buffer_initial_length, T_FIXNUM);
    initial_length = FIX2LONG(buffer_initial_length);
    if (initial_length &gt; 0) {
        state-&gt;buffer_initial_length = initial_length;
    }
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_circular-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          check_circular?
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true, if circular data structures should be checked, otherwise returns false.</p>

                              <div class="method-source-code" id="check_circular-3F-source">
            <pre>static VALUE cState_check_circular_p(VALUE self)
{
    GET_STATE(self);
    return state-&gt;max_nesting ? Qtrue : Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-configure" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          configure(opts)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Configure this <a href="State.html"><code>State</code></a> instance with the Hash <em>opts</em>, and return itself.</p>

                              <div class="method-source-code" id="configure-source">
            <pre>static VALUE cState_configure(VALUE self, VALUE opts)
{
    VALUE tmp;
    GET_STATE(self);
    tmp = rb_check_convert_type(opts, T_HASH, &quot;Hash&quot;, &quot;to_hash&quot;);
    if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, &quot;Hash&quot;, &quot;to_h&quot;);
    opts = tmp;
    tmp = rb_hash_aref(opts, ID2SYM(i_indent));
    if (RTEST(tmp)) {
        unsigned long len;
        Check_Type(tmp, T_STRING);
        len = RSTRING_LEN(tmp);
        state-&gt;indent = fstrndup(RSTRING_PTR(tmp), len + 1);
        state-&gt;indent_len = len;
    }
    tmp = rb_hash_aref(opts, ID2SYM(i_space));
    if (RTEST(tmp)) {
        unsigned long len;
        Check_Type(tmp, T_STRING);
        len = RSTRING_LEN(tmp);
        state-&gt;space = fstrndup(RSTRING_PTR(tmp), len + 1);
        state-&gt;space_len = len;
    }
    tmp = rb_hash_aref(opts, ID2SYM(i_space_before));
    if (RTEST(tmp)) {
        unsigned long len;
        Check_Type(tmp, T_STRING);
        len = RSTRING_LEN(tmp);
        state-&gt;space_before = fstrndup(RSTRING_PTR(tmp), len + 1);
        state-&gt;space_before_len = len;
    }
    tmp = rb_hash_aref(opts, ID2SYM(i_array_nl));
    if (RTEST(tmp)) {
        unsigned long len;
        Check_Type(tmp, T_STRING);
        len = RSTRING_LEN(tmp);
        state-&gt;array_nl = fstrndup(RSTRING_PTR(tmp), len + 1);
        state-&gt;array_nl_len = len;
    }
    tmp = rb_hash_aref(opts, ID2SYM(i_object_nl));
    if (RTEST(tmp)) {
        unsigned long len;
        Check_Type(tmp, T_STRING);
        len = RSTRING_LEN(tmp);
        state-&gt;object_nl = fstrndup(RSTRING_PTR(tmp), len + 1);
        state-&gt;object_nl_len = len;
    }
    tmp = ID2SYM(i_max_nesting);
    state-&gt;max_nesting = 100;
    if (option_given_p(opts, tmp)) {
        VALUE max_nesting = rb_hash_aref(opts, tmp);
        if (RTEST(max_nesting)) {
            Check_Type(max_nesting, T_FIXNUM);
            state-&gt;max_nesting = FIX2LONG(max_nesting);
        } else {
            state-&gt;max_nesting = 0;
        }
    }
    tmp = ID2SYM(i_depth);
    state-&gt;depth = 0;
    if (option_given_p(opts, tmp)) {
        VALUE depth = rb_hash_aref(opts, tmp);
        if (RTEST(depth)) {
            Check_Type(depth, T_FIXNUM);
            state-&gt;depth = FIX2LONG(depth);
        } else {
            state-&gt;depth = 0;
        }
    }
    tmp = ID2SYM(i_buffer_initial_length);
    if (option_given_p(opts, tmp)) {
        VALUE buffer_initial_length = rb_hash_aref(opts, tmp);
        if (RTEST(buffer_initial_length)) {
            long initial_length;
            Check_Type(buffer_initial_length, T_FIXNUM);
            initial_length = FIX2LONG(buffer_initial_length);
            if (initial_length &gt; 0) state-&gt;buffer_initial_length = initial_length;
        }
    }
    tmp = rb_hash_aref(opts, ID2SYM(i_allow_nan));
    state-&gt;allow_nan = RTEST(tmp);
    tmp = rb_hash_aref(opts, ID2SYM(i_ascii_only));
    state-&gt;ascii_only = RTEST(tmp);
    tmp = rb_hash_aref(opts, ID2SYM(i_escape_slash));
    state-&gt;escape_slash = RTEST(tmp);
    return self;
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="State.html#method-i-merge">merge</a>
                            </div>

                          </div>

                  <div id="method-i-depth" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          depth
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This integer returns the current depth of data structure nesting.</p>

                              <div class="method-source-code" id="depth-source">
            <pre>static VALUE cState_depth(VALUE self)
{
    GET_STATE(self);
    return LONG2FIX(state-&gt;depth);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-depth-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          depth=(depth)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This sets the maximum level of data structure nesting in the generated <a href="../../../JSON.html"><code>JSON</code></a> to the integer depth, <a href="State.html#method-i-max_nesting"><code>max_nesting</code></a> = 0 if no maximum should be checked.</p>

                              <div class="method-source-code" id="depth-3D-source">
            <pre>static VALUE cState_depth_set(VALUE self, VALUE depth)
{
    GET_STATE(self);
    Check_Type(depth, T_FIXNUM);
    state-&gt;depth = FIX2LONG(depth);
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-escape_slash" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          escape_slash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>If this boolean is true, the forward slashes will be escaped in the json output.</p>

                              <div class="method-source-code" id="escape_slash-source">
            <pre>static VALUE cState_escape_slash(VALUE self)
{
    GET_STATE(self);
    return state-&gt;escape_slash ? Qtrue : Qfalse;
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="State.html#method-i-escape_slash-3F">escape_slash?</a>
                            </div>

                          </div>

                  <div id="method-i-escape_slash-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          escape_slash=(depth)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This sets whether or not the forward slashes will be escaped in the json output.</p>

                              <div class="method-source-code" id="escape_slash-3D-source">
            <pre>static VALUE cState_escape_slash_set(VALUE self, VALUE enable)
{
    GET_STATE(self);
    state-&gt;escape_slash = RTEST(enable);
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-escape_slash-3F" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">escape_slash?</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              <p>If this boolean is true, the forward slashes will be escaped in the json output.</p>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="State.html#method-i-escape_slash">escape_slash</a>
                            </div>
                          </div>

                  <div id="method-i-generate" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          generate(obj)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Generates a valid <a href="../../../JSON.html"><code>JSON</code></a> document from object <code>obj</code> and returns the result. If no valid <a href="../../../JSON.html"><code>JSON</code></a> document can be created this method raises a <a href="../../GeneratorError.html"><code>GeneratorError</code></a> exception.</p>

                              <div class="method-source-code" id="generate-source">
            <pre>static VALUE cState_generate(VALUE self, VALUE obj)
{
    VALUE result = cState_partial_generate(self, obj);
    GET_STATE(self);
    (void)state;
    return result;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-indent" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          indent()
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the string that is used to indent levels in the <a href="../../../JSON.html"><code>JSON</code></a> text.</p>

                              <div class="method-source-code" id="indent-source">
            <pre>static VALUE cState_indent(VALUE self)
{
    GET_STATE(self);
    return state-&gt;indent ? rb_str_new(state-&gt;indent, state-&gt;indent_len) : rb_str_new2(&quot;&quot;);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-indent-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          indent=(indent)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the string that is used to indent levels in the <a href="../../../JSON.html"><code>JSON</code></a> text.</p>

                              <div class="method-source-code" id="indent-3D-source">
            <pre>static VALUE cState_indent_set(VALUE self, VALUE indent)
{
    unsigned long len;
    GET_STATE(self);
    Check_Type(indent, T_STRING);
    len = RSTRING_LEN(indent);
    if (len == 0) {
        if (state-&gt;indent) {
            ruby_xfree(state-&gt;indent);
            state-&gt;indent = NULL;
            state-&gt;indent_len = 0;
        }
    } else {
        if (state-&gt;indent) ruby_xfree(state-&gt;indent);
        state-&gt;indent = fstrndup(RSTRING_PTR(indent), len);
        state-&gt;indent_len = len;
    }
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-initialize_copy" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          initialize_copy(orig)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Initializes this object from orig if it can be duplicated/cloned and returns it.</p>

                              <div class="method-source-code" id="initialize_copy-source">
            <pre>static VALUE cState_init_copy(VALUE obj, VALUE orig)
{
    JSON_Generator_State *objState, *origState;

    if (obj == orig) return obj;
    GET_STATE_TO(obj, objState);
    GET_STATE_TO(orig, origState);
    if (!objState) rb_raise(rb_eArgError, &quot;unallocated JSON::State&quot;);

    MEMCPY(objState, origState, JSON_Generator_State, 1);
    objState-&gt;indent = fstrndup(origState-&gt;indent, origState-&gt;indent_len);
    objState-&gt;space = fstrndup(origState-&gt;space, origState-&gt;space_len);
    objState-&gt;space_before = fstrndup(origState-&gt;space_before, origState-&gt;space_before_len);
    objState-&gt;object_nl = fstrndup(origState-&gt;object_nl, origState-&gt;object_nl_len);
    objState-&gt;array_nl = fstrndup(origState-&gt;array_nl, origState-&gt;array_nl_len);
    if (origState-&gt;array_delim) objState-&gt;array_delim = fbuffer_dup(origState-&gt;array_delim);
    if (origState-&gt;object_delim) objState-&gt;object_delim = fbuffer_dup(origState-&gt;object_delim);
    if (origState-&gt;object_delim2) objState-&gt;object_delim2 = fbuffer_dup(origState-&gt;object_delim2);
    return obj;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-max_nesting" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          max_nesting
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This integer returns the maximum level of data structure nesting in the generated <a href="../../../JSON.html"><code>JSON</code></a>, <a href="State.html#method-i-max_nesting"><code>max_nesting</code></a> = 0 if no maximum is checked.</p>

                              <div class="method-source-code" id="max_nesting-source">
            <pre>static VALUE cState_max_nesting(VALUE self)
{
    GET_STATE(self);
    return LONG2FIX(state-&gt;max_nesting);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-max_nesting-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          max_nesting=(depth)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This sets the maximum level of data structure nesting in the generated <a href="../../../JSON.html"><code>JSON</code></a> to the integer depth, <a href="State.html#method-i-max_nesting"><code>max_nesting</code></a> = 0 if no maximum should be checked.</p>

                              <div class="method-source-code" id="max_nesting-3D-source">
            <pre>static VALUE cState_max_nesting_set(VALUE self, VALUE depth)
{
    GET_STATE(self);
    Check_Type(depth, T_FIXNUM);
    return state-&gt;max_nesting = FIX2LONG(depth);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-merge" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">merge</span><span
                                class="method-args">(p1)</span>
                            </div>

                            <div class="method-description">
                              <p>Configure this <a href="State.html"><code>State</code></a> instance with the Hash <em>opts</em>, and return itself.</p>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="State.html#method-i-configure">configure</a>
                            </div>
                          </div>

                  <div id="method-i-object_nl" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          object_nl()
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This string is put at the end of a line that holds a <a href="../../../JSON.html"><code>JSON</code></a> object (or Hash).</p>

                              <div class="method-source-code" id="object_nl-source">
            <pre>static VALUE cState_object_nl(VALUE self)
{
    GET_STATE(self);
    return state-&gt;object_nl ? rb_str_new(state-&gt;object_nl, state-&gt;object_nl_len) : rb_str_new2(&quot;&quot;);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-object_nl-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          object_nl=(object_nl)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>This string is put at the end of a line that holds a <a href="../../../JSON.html"><code>JSON</code></a> object (or Hash).</p>

                              <div class="method-source-code" id="object_nl-3D-source">
            <pre>static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
{
    unsigned long len;
    GET_STATE(self);
    Check_Type(object_nl, T_STRING);
    len = RSTRING_LEN(object_nl);
    if (len == 0) {
        if (state-&gt;object_nl) {
            ruby_xfree(state-&gt;object_nl);
            state-&gt;object_nl = NULL;
        }
    } else {
        if (state-&gt;object_nl) ruby_xfree(state-&gt;object_nl);
        state-&gt;object_nl = fstrndup(RSTRING_PTR(object_nl), len);
        state-&gt;object_nl_len = len;
    }
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-space" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          space()
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the string that is used to insert a space between the tokens in a <a href="../../../JSON.html"><code>JSON</code></a> string.</p>

                              <div class="method-source-code" id="space-source">
            <pre>static VALUE cState_space(VALUE self)
{
    GET_STATE(self);
    return state-&gt;space ? rb_str_new(state-&gt;space, state-&gt;space_len) : rb_str_new2(&quot;&quot;);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-space-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          space=(space)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets <em>space</em> to the string that is used to insert a space between the tokens in a <a href="../../../JSON.html"><code>JSON</code></a> string.</p>

                              <div class="method-source-code" id="space-3D-source">
            <pre>static VALUE cState_space_set(VALUE self, VALUE space)
{
    unsigned long len;
    GET_STATE(self);
    Check_Type(space, T_STRING);
    len = RSTRING_LEN(space);
    if (len == 0) {
        if (state-&gt;space) {
            ruby_xfree(state-&gt;space);
            state-&gt;space = NULL;
            state-&gt;space_len = 0;
        }
    } else {
        if (state-&gt;space) ruby_xfree(state-&gt;space);
        state-&gt;space = fstrndup(RSTRING_PTR(space), len);
        state-&gt;space_len = len;
    }
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-space_before" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          space_before()
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the string that is used to insert a space before the ‘:’ in <a href="../../../JSON.html"><code>JSON</code></a> objects.</p>

                              <div class="method-source-code" id="space_before-source">
            <pre>static VALUE cState_space_before(VALUE self)
{
    GET_STATE(self);
    return state-&gt;space_before ? rb_str_new(state-&gt;space_before, state-&gt;space_before_len) : rb_str_new2(&quot;&quot;);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-space_before-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          space_before=(space_before)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the string that is used to insert a space before the ‘:’ in <a href="../../../JSON.html"><code>JSON</code></a> objects.</p>

                              <div class="method-source-code" id="space_before-3D-source">
            <pre>static VALUE cState_space_before_set(VALUE self, VALUE space_before)
{
    unsigned long len;
    GET_STATE(self);
    Check_Type(space_before, T_STRING);
    len = RSTRING_LEN(space_before);
    if (len == 0) {
        if (state-&gt;space_before) {
            ruby_xfree(state-&gt;space_before);
            state-&gt;space_before = NULL;
            state-&gt;space_before_len = 0;
        }
    } else {
        if (state-&gt;space_before) ruby_xfree(state-&gt;space_before);
        state-&gt;space_before = fstrndup(RSTRING_PTR(space_before), len);
        state-&gt;space_before_len = len;
    }
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_h" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_h
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the configuration instance variables as a hash, that can be passed to the configure method.</p>

                              <div class="method-source-code" id="to_h-source">
            <pre>static VALUE cState_to_h(VALUE self)
{
    VALUE result = rb_hash_new();
    GET_STATE(self);
    set_state_ivars(result, self);
    rb_hash_aset(result, ID2SYM(i_indent), rb_str_new(state-&gt;indent, state-&gt;indent_len));
    rb_hash_aset(result, ID2SYM(i_space), rb_str_new(state-&gt;space, state-&gt;space_len));
    rb_hash_aset(result, ID2SYM(i_space_before), rb_str_new(state-&gt;space_before, state-&gt;space_before_len));
    rb_hash_aset(result, ID2SYM(i_object_nl), rb_str_new(state-&gt;object_nl, state-&gt;object_nl_len));
    rb_hash_aset(result, ID2SYM(i_array_nl), rb_str_new(state-&gt;array_nl, state-&gt;array_nl_len));
    rb_hash_aset(result, ID2SYM(i_allow_nan), state-&gt;allow_nan ? Qtrue : Qfalse);
    rb_hash_aset(result, ID2SYM(i_ascii_only), state-&gt;ascii_only ? Qtrue : Qfalse);
    rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state-&gt;max_nesting));
    rb_hash_aset(result, ID2SYM(i_escape_slash), state-&gt;escape_slash ? Qtrue : Qfalse);
    rb_hash_aset(result, ID2SYM(i_depth), LONG2FIX(state-&gt;depth));
    rb_hash_aset(result, ID2SYM(i_buffer_initial_length), LONG2FIX(state-&gt;buffer_initial_length));
    return result;
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="State.html#method-i-to_hash">to_hash</a>
                            </div>

                          </div>

                  <div id="method-i-to_hash" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">to_hash</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the configuration instance variables as a hash, that can be passed to the configure method.</p>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="State.html#method-i-to_h">to_h</a>
                            </div>
                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

